<template lang="">
     <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady" 
           style="height:100%" class='ag-theme-alpine'
           :defaultColDef="defaultColDef" :rowData="table.dataList" 
           :columnDefs="cfsValue" :localeText="localeTextData"/>
     <!-- <paginationCopys :total="total" show-total show-jumper 
         show-page-size @change="changePage"  @page-size-change="changeSize" 
         style="justify-content: center;margin-top: 10px;"  :page-size="pagination.pageSize"
         :current="pagination.page" /> -->
</template>
<script lang="ts">
 
 import { localeText } from '@/api/aggridZw'
 import emitter from "@/hooks/useEventBus";
 import { onMounted,reactive, ref } from 'vue';
 import { usePagination, useTable } from '@/hooks/table';
 import { verifyManage } from '@/api/PhysicalSurveyRoom/physicalTestApi';
import { Message } from '@arco-design/web-vue';
export default {
    components: {  },
    props:{
        searchData:{
           type:Object,
           default:() => {}
        }
     },
     setup(props,){
         const verifyManageApi = verifyManage();
         onMounted(() => {
             // 第一个页面需要在刚进入就调用一次  切换tap时也需要调用
            //  doRefresh();
             emitter.on("refresh-phyMeasurChart", () => {
                 doRefresh();
             });
         });
         const doRefresh = async () => {
            await verifyManageApi.geVerifyResultSummary({     
                // page: pagination.page,
                // size: pagination.pageSize,
                ...props.searchData, }).then(({code,data,message}: any) => {
                if (code === 200) {
                    table.handleSuccess(data);
                    gridOption.value.setRowData(data);
                    total.value = data.total;
                } else {
                    Message.error({
                        content: message,
                        duration: 2000
                    });
                }
            });
         };
         //表格方面
         const gridOption = ref();
         const gridReady = (params:any) => {
           gridOption.value = params.api;
           //调整表格自适应大小
         }
         const defaultColDef = {
             sortable: true,
             resizable: true,
             filter: true,
             width: 150
             // flex: 1
         }
        let cfsValue:any = [
        {
                headerName: "测试类型",
                field: "verifyPorject",
            },
            {
                headerName: "总数",
                field: "totalNum",
            },
            {
                headerName: "合格数",
                field: "qualified",
            },
            {
                headerName: "不合格",
                field: "unQualified",
            },
            {
                headerName: "合格率",
                field: "qualifiedRate",
                cellRenderer:{
                    template:`<span>{{qualifiedRate+'%'}}</span>`,
                    setup(props:any){
                       let {qualifiedRate} = props.params.data;
                       return {
                        qualifiedRate
                       }
                    }
                }
            },
         ];
         const total = ref(10);
         const changePage = (val:any) => {
             pagination.page = val
             doRefresh();
         }
         const changeSize = (val:any) => {
             pagination.pageSize = val
             doRefresh();
         }
 
         const localeTextData :any = ref(localeText);
         const pagination = usePagination(doRefresh);
         const table = useTable();
         return {
             pagination,
             table,
             localeTextData,
             changePage,
             changeSize,
             total,
             cfsValue,
             defaultColDef,
             gridReady,
         }
     },
}
</script>
<style lang="less" scoped> 
    
</style> 